package com.winit.schedule.core.model;

public class TaskID implements ID {

    private String taskId;

    private JobID  jobId;

    public TaskID(){
    }

    public TaskID(String taskId){
        this.taskId = taskId;
    }

    public TaskID(JobID jobId, String taskId){
        this(taskId);
        this.jobId = jobId;
    }

    public JobID getJobId() {
        return jobId;
    }

    public void setJobId(JobID jobId) {
        this.jobId = jobId;
    }

    @Override
    public boolean equals(Object o) {
        TaskID that = (TaskID) o;
        if (null == jobId || null == that.jobId) {
            return false;
        }
        if (!that.jobId.equals(this.jobId)) {
            return false;
        }

        return this.taskId.equals(that.taskId);
    }

    @Override
    public int hashCode() {
        int hashCode = 31 * 17 + this.taskId.hashCode();
        if (this.jobId != null) {
            hashCode = hashCode * 31 + this.jobId.hashCode();
        }
        return hashCode;
    }

    public String toString() {
        String str = this.taskId;
        if (null != this.jobId) {
            str = this.jobId.getId() + "$" + str;
        }
        return str;
    }

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    @Override
    public String getId() {
        return (null != this.jobId ? this.jobId.getJobId() + "$" : "") + this.taskId;
    }
}
